<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="org.apache.shiro.web.filter.authc.FormAuthenticationFilter"%>
<%@ page import="org.apache.shiro.authc.ExcessiveAttemptsException"%>
<%@ page import="org.apache.shiro.authc.IncorrectCredentialsException"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
	<title>用户列表</title>
<script>

$(document).ready(function() {
	mz_datatbles.dt();
});
var url="${ctx}/user/user/list";
var oTable;
mz_datatbles = {
	dt:function(){
		if($('#listTable').length) {
			oTable = $("#listTable").dataTable({
	    		"fnServerParams": function ( aoData ) {
	    			jQuery.each( $("form#listForm").serializeArray(), function(i, field){
	    				aoData.push( field );    
					});
	    		} ,    
	        	"bServerSide": true,
	        	"bProcessing": true,
	        	"bSort" : true, 
	        	"sPaginationType": "bootstrap",
	        	"sDom": "<r>t<'row'<'span6'li><'span6'p>>",
	        	"sAjaxSource": url,
	        	"oLanguage": {  
	        		"sProcessing": "数据加载中",
	        		"sLoadingRecords": "Please wait - loading...",
	        		"sLengthMenu": "每页显示 _MENU_ 行&nbsp;",
	        		"sSearch": "_INPUT_",
	        		"oPaginate": {       "sFirst": "首页" ,  "sPrevious": "前页" ,"sNext": "下页", "sLast": "尾页"     },
	        		"sZeroRecords": "未找到符合条件的数据",
	        		"sEmptyTable": "未找到符合条件的数据"
	        	} ,
	       	 	"aoColumns": [
					{ "mDataProp": "loginName", "sName": "loginName", "sClass": "center" },
					{ "mDataProp": "email", "sName": "email", "sClass": "center" },
					{ "mDataProp": "createdBy", "sName": "createdBy", "sClass": "center" },
					{ "mDataProp": "createdTimeStr", "sName": "createdTimeStr", "sClass": "center" },
					{ "mDataProp": "modifyBy", "sName": "modifyBy", "sClass": "center" },
					{ "mDataProp": "modifyTimeStr", "sName": "modifyTimeStr", "sClass": "center" },
					{ "bSortable": false, "mDataProp": null, "sClass": "center",
						"fnRender" : function(oObj) {
							var status = oObj.aData.status;
							var html =
							'<a title="查看" class="sepV_a" href="${ctx}/user/user/view/'+oObj.aData.id+'">' +
							'<i class="icon-eye-open"></i></a>';
							html=html +
								'<a title="修改" class="sepV_a" href="${ctx}/user/user/update/'+oObj.aData.id+'">' +
								'<i class="icon-pencil"></i></a>';
								
								html=html  +
								'<a title="删除" class="sepV_a" onclick="return delConfirm()" href="${ctx}/user/user/delete/'+oObj.aData.id+'">' +
								'<i class="icon-trash"></i></a>';
							return html; 
						}
					}
				] ,
				"fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre) {
	        		getFrameHeight();
	        		return "&nbsp;"+(iTotal>0?iStart:0)+" ~ "+iEnd+" 行 总共"+iTotal+"行 ";  
	        	} 
	    	});
		}
	}
};
var message = '${message}';
if(message!=null && message!=""){
	alert(message)
} 
function delConfirm(){
	if(confirm("是否真的确定删除该用户?")){
		return true;
	}else{
		return false;
	}
}

function toSave(){
	window.location.href = "${ctx}/user/user/create";
}
</script>
</head>

<body>
        	<div>
            	<div id="jCrumbs" class="breadCrumb module">
				   <ul>
					   <li>
				           <a href="#"><i class="icon-home" style="margin-top: 2px;"></i></a>
				       </li>
				       <li>
				            	用户管理
				       </li>
				   </ul>
				</div>
				<div class="row-fluid">
		    		<div class="span12">
		        		<div class="row-fluid">
							<div class="span12">
								<form name="listForm" id="listForm">
									<table class="table table-bordered table-striped table_vam dataTable">
										<tbody>
											<tr>
												<th>用户名</th>
												<td>
													<input type="text" name="loginName" />
												 </td>
											</tr>
											<tr>
												<td colspan="4">								
													<div class="row">
														<div class="span4">
															<div class="dt_actions"><div class="btn-group"></div></div>
														</div>
														<div class="span4 center">
															 <button class="btn  btn_search" type="button" onclick="oTable.fnDraw();">查询</button>&nbsp;&nbsp;&nbsp;&nbsp;
															<button class="btn" type="reset">重置</button> 
														</div>
														<div class="span4">
															<div class="btn-group pull-right">
																<button class="btn" style="background-color: #D7E6FA" type="button" onclick="toSave()">新增用户</button>
															</div>
														</div>
													</div>
												</td>
											</tr>
										</tbody>
									</table>
								</form>
							</div>
						</div>
					<table id="listTable" class="table table-bordered table-striped table_vam dataTable">
		            	<thead>
		                	<tr>
								<th>用户名</th>
								 <th>邮箱</th>
								<th>创建人</th>
								<th>创建时间</th>
								<th>修改人</th>
								<th>修改时间</th>
								<th class="center sorting">操作</th>
							</tr>
		            	</thead>
		            	<tbody>
		                	<tr>
		                    	<td class="dataTables_empty" colspan="7"></td>
		                	</tr>
		            	</tbody>
		        	</table>
		        </div>
		    </div>
		</div>
</body>
</html>
